<script language="JavaScript"> 
<!-- hide 

function openWin3(msg) { 
  myWin= open("", "displayWindow", 
    "width=500,height=400,status=yes,toolbar=yes,menubar=yes"); 

  // open document for further output 
  myWin.document.open(); 
  
  // create document 
  myWin.document.write("<html><head><title>Case Hearing Lapses Notification"); 
  myWin.document.write("</title></head><body>"); 
  myWin.document.write("<center><font size=+1>Case Hearing Lapses Notification</font><br>"); 
  myWin.document.write(msg); 
  myWin.document.write("</center></body></html>"); 

  // close the document - (not the window!) 
  myWin.document.close();  
} 

// --> 
</script>

<?php

/*

 
echo $newdate;
*/
	$thisyear = date('Y');
	$today = date('Y-m-d');
	$startofyear= strtotime ( 'January 01' , strtotime ( $thisyear ) ) ;
	$thirtyday = date ( 'Y-m-d' , $startofyear);
//	echo $thirtyday."<br>".$today;
	include('connect-db.php');
//	$sql_script = "SELECT * FROM casereferred, schedule WHERE casereferred.caseNo = schedule.caseNo AND casereferred.caseStatus='YES' AND schedule.Date BETWEEN '".$thirtyday."' AND '".$today."'";
	$sql_script = "SELECT * FROM casereferred WHERE dateRegister BETWEEN '".$thirtyday."' AND '".$today."'";				
	$result = mysql_query($sql_script) or die(mysql_error());
    $caseThisMonth = mysql_num_rows($result);


	echo    '<table border="0" style="width: 300;height:100; background-color:#ffffff">';
	echo    '<tr>';
	echo    '<td style="background-color:#ffffff"><img alt="cases" src="casesicon.jpg" width="100" height="100" /></td>';
	echo    '<td style="text-align:center;margin-left:auto;margin-right:auto;line-height:1.5em;background-color:#ffffff">';
	echo    '<span style="font-family: Arial,Helvetica,sans-serif;font-size: 20pt">'. $caseThisMonth.'</span>';
	echo    '<p><strong  style="font-family: Arial,Helvetica,sans-serif;font-size: 15pt;background-color:#ffffff">Received Cases Year-to-date</strong></p>';
	echo    '</td> </tr> </table>';
	if (!strcmp($_SESSION['memberType'],"Admin") || !strcmp($_SESSION['memberType'],"PMC_Staff")) 
	{
			if (!($pgcount % 3)){
			    //date computation - 3 days before due date
				    $today = date('Y-m-d');
					$sched_date = strtotime ( '-27 day' , strtotime ( $today ) ) ;
					$sched_date = date ( 'Y-m-j' , $sched_date );
					$due_date = strtotime ( '-24 day' , strtotime ( $today ) ) ;
					$due_date = date ( 'Y-m-j' , $due_date );

					//echo "$due_date - $sched_date";
					include('connect-db.php');
					$sql_script = "SELECT casereferred.caseNo, casereferred.plaintiffName, casereferred.defendantName, schedule.Date FROM casereferred, schedule WHERE casereferred.caseNo = schedule.caseNo AND casereferred.caseStatus='YES' AND schedule.Date BETWEEN '".$sched_date."' AND '".$due_date."'";
					
					$result = mysql_query($sql_script) or die(mysql_error());
					
					$html_script = "<table border=1 cellpadding=2><tr><th>Case Number</th><th>Case Title</th><th>Hearing Date</th><th>Due Date</th></tr>";
					//echo "Due:".$due_date." * Actual".$actual_due." *Schedule:".$sched_date;
					//exit;
					$found = 0;
					while($row_data = mysql_fetch_array($result)){
					     $found++;
						 $actual_due = strtotime('+31 day',strtotime($row_data['Date']));
					     $actual_due = date ( 'Y-m-j' , $actual_due );
					     $html_script .= "<tr><td>".$row_data['caseNo']."</td><td>".$row_data['plaintiffName']." vs. ".$row_data['defendantName']."</td><td>".$row_data['Date']."</td><td>".$actual_due."</td></tr>";
					}
					$html_script .= "</table>";
					if($found>0){
							//echo "***";
							echo    "<body bgcolor=\"ffffff\" text=\"000000\" link=\"0000ff\" vlink=\"0000ff\" onLoad=\"openWin3('$html_script')\">";
					}
			}
	}
?>